<template>
  <div>
    <el-table height="70vh" ref="table" highlight-current-row
              :header-cell-style="{background:'#F0F8FF',color:'#000000',fontWeight:'bold'}"
              v-loading="loading" :data="sbxxglList">
      <!--      <el-table-column type="selection" width="55" align="center"/>-->
      <el-table-column label="序号" align="center" type="index" :index="indexMethod"/>
      <el-table-column label="设备名称" align="center" prop="sbName" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleButtonClick(scope.row)"
          >
            <el-link style="font-weight: 600" type="primary">{{ scope.row.sbName }}</el-link>
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="出厂编号" align="center" prop="ccBh" show-overflow-tooltip/>
      <el-table-column label="自编号" align="center" prop="zbh" show-overflow-tooltip/>
      <el-table-column label="固定资产编号" align="center" prop="gdZcBh" show-overflow-tooltip/>
      <el-table-column label="校准周期" align="center" prop="jzZq" show-overflow-tooltip/>
      <el-table-column label="规格型号" align="center" prop="ggXh" show-overflow-tooltip/>
      <el-table-column label="所在项目" align="center" prop="szXm" show-overflow-tooltip/>
      <el-table-column label="单位" align="center" prop="dw" show-overflow-tooltip/>
      <el-table-column label="设备类型" align="center" prop="sbLx" show-overflow-tooltip>
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sbgl_sblx" :value="scope.row.sbLx"/>
        </template>
      </el-table-column>
      <el-table-column label="测量范围" align="center" prop="clFw" show-overflow-tooltip/>
      <el-table-column label="有效期至" align="center" prop="yxqZ" width="110" show-overflow-tooltip>
        <template slot-scope="scope">
          <span style="color: red">{{ parseTime(scope.row.yxqZ, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

    <!-- 设备详情 -->
    <SbXq ref="sbXq"/>
  </div>
</template>

<script>
import {selectSjyjList} from "@/api/sbgl/sbxxgl";
import ImagePreviewBase64 from "@/components/ImagePreviewBase64/index.vue";
import SbXq from "@/views/sbgl/sbxxgl/components/SbXq.vue";

export default {
  name: "SjYjLb",//送检预警列表
  components: {SbXq, ImagePreviewBase64},
  dicts: ['sbgl_sblx', 'sbgl_sbdw', 'sbgl_sbzt'],
  created() {
    this.getList();
  },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        idWhere: null,
        sbName: null,
        ccBh: null,
        zbh: null,
        jzZq: null,
        ggXh: null,
        szXm: null,
        sbLx: null,
        yxqZ: null,
        userId: null,
        deptId: null,
        gdZcBh: null,
        sbZt: null,
      },
      // 总条数
      total: 0,
      loading: false,
      // 设备预警表格数据
      sbxxglList: [],
    }
  },
  methods: {
    getList() {
      this.loading = true;
      selectSjyjList(this.queryParams).then(res => {
        this.sbxxglList = res.rows;
        this.total = res.total;
        this.loading = false;
      })
    },
    /** 自定义序号 */
    indexMethod(index) {
      let pageNum = this.queryParams.pageNum - 1;
      if ((pageNum !== -1 && pageNum !== 0)) {
        return (index + 1) + (pageNum * this.queryParams.pageSize);
      } else {
        return (index + 1)
      }
    },
    // 查询设备详情信息
    handleButtonClick(row) {
      this.$refs.sbXq.handleOpen(row);
    },

  }
}
</script>

<style scoped>

</style>
